home *** CD-ROM | disk | FTP | other *** search
- #include "GenerateIndex.h"
-
- extern struct TagItem MainOutline[], RefOutline[], OptionsOutline[], ScanStatOutline[];
- extern struct Library *TritonBase;
-
- struct rtFileRequester *DataFileReq, *AddFileReq, *PrefsFileReq;
- struct TR_Project *MainPrj, *RefPrj, *OptionsPrj, *ScanStatPrj;
-
- BOOL GoOn = TRUE, FileChanged;
-
- /// About()
- void
- About(void)
- {
- rtEZRequestTags("GenerateIndex " VERSION " (" DATE ")\n"
- "Index file generator for FetchRefs\n"
- "\n"
- "By Anders Melchiorsen\n"
- "\n"
- "FreeWare, 1994-1996",
-
- "Okay",
-
- NULL, NULL,
-
- RTEZ_Flags, EZREQF_CENTERTEXT,
- TAG_END, NULL
- );
- }
- ///
- /// OpenRefWindow()
- void
- OpenRefWindow(void)
- {
- if (!RefPrj)
- {
- /* We call UpdateMain() because it also updates the text gadget
- * with the file name of the ref window.
- */
- if (RefPrj = TR_OpenProject(Application, RefOutline))
- UpdateMain();
- } else
- {
- struct Window *win;
-
- /* Bring the ref window to the front */
- if (win = TR_ObtainWindow(RefPrj))
- {
- WindowToFront(win);
- ActivateWindow(win);
- TR_ReleaseWindow(win);
- }
- }
- }
- ///
- /// OpenScanStatWindow()
- void
- OpenScanStatWindow(void)
- {
- if (TritonBase)
- ScanStatPrj = TR_OpenProject(Application, ScanStatOutline);
- }
- ///
- /// CloseScanStatWindow()
- void
- CloseScanStatWindow(void)
- {
- if (ScanStatPrj)
- TR_CloseProject(ScanStatPrj);
- ScanStatPrj = NULL;
- }
- ///
-
- /// GiveHelp() - open guide positioned at the help for <id>
- #include "HelpTable.h"
-
- void
- GiveHelp(LONG id, struct Screen *scr)
- {
- struct Library *AmigaGuideBase;
- struct NewAmigaGuide nag = { NULL };
- AMIGAGUIDECONTEXT handle;
- LONG cnt;
-
- LockGUI();
-
- nag.nag_Name = "FetchRefs_GI.guide";
- nag.nag_Screen = scr;
-
- for (cnt = 0; HelpTable[cnt].id; cnt++)
- if (HelpTable[cnt].id == id)
- break;
- nag.nag_Node = HelpTable[cnt].node;
- nag.nag_Line = HelpTable[cnt].line;
-
- /* Show the guide */
- if (AmigaGuideBase = OpenLibrary("amigaguide.library", 34))
- {
- if (handle = OpenAmigaGuideA(&nag, NULL))
- CloseAmigaGuide(handle);
- else
- PostMessage("Could not open guide");
-
- CloseLibrary(AmigaGuideBase);
- } else
- PostMessage("Could not open amigaguide.library v34+");
-
- UnlockGUI();
- }
- ///
- /// LockGUI()
- void
- LockGUI(void)
- {
- TR_LockProject(MainPrj);
- if (RefPrj)
- TR_LockProject(RefPrj);
- if (OptionsPrj)
- TR_LockProject(OptionsPrj);
- }
- ///
- /// UnlockGUI()
- void
- UnlockGUI(void)
- {
- TR_UnlockProject(MainPrj);
- if (RefPrj)
- TR_UnlockProject(RefPrj);
- if (OptionsPrj)
- TR_UnlockProject(OptionsPrj);
- }
- ///
-
- /// AttachMainList()
- void
- AttachMainList(struct List *newlist)
- {
- static struct List *lastlist = &FileList;
-
- if (!newlist)
- newlist = lastlist;
- else
- lastlist = newlist;
-
- if (MainPrj)
- {
- TR_SetAttribute(MainPrj, MAIN_LIST_ID, NULL, (ULONG) newlist);
-
- if (newlist == &FileList)
- UpdateMain();
- }
- }
- ///
- /// DetachMainList()
- void
- DetachMainList(void)
- {
- if (MainPrj)
- TR_SetAttribute(MainPrj, MAIN_LIST_ID, NULL, (ULONG) ~0);
- }
- ///
- /// AttachRefList()
- void
- AttachRefList(void)
- {
- struct FileEntry *f;
-
- if (RefPrj)
- {
- f = SelectedMain();
- TR_SetAttribute(RefPrj, REF_LIST_ID, NULL, (ULONG) (f ? &f->RefsList : &EmptyList));
- }
- }
- ///
- /// DetachRefList()
- void
- DetachRefList(void)
- {
- if (RefPrj)
- TR_SetAttribute(RefPrj, REF_LIST_ID, NULL, (ULONG) ~0);
- }
- ///
-
- /// DeleteSelectedFile()
- void
- DeleteSelectedFile(void)
- {
- struct FileEntry *f;
-
- if (f = SelectedMain())
- {
- DetachMainList();
- FreeFile(f);
- AttachMainList(NULL);
- UpdateMain();
-
- FileChanged = TRUE;
- }
- }
- ///
- /// DeleteSelectedReference()
- void
- DeleteSelectedReference(void)
- {
- struct RefsEntry *r;
-
- if (r = SelectedRef())
- {
- FreeRef(r);
- FileChanged = TRUE;
- }
- }
- ///
- /// RescanAllFiles()
- void
- RescanAllFiles(void)
- {
- struct Node *n, *next;
-
- for (next = GetHead(&FileList); n = next, next = next->ln_Succ; )
- {
- /* If the user break (window is closed) the list is not sorted
- * so we do that before returning.
- */
- if (!ScanStatPrj)
- {
- SortExecList(&FileList, SortCompareFunc, NULL);
- break;
- }
-
- /* Rescan this one. This may delete the entry, so we have cached
- * a pointer to the next.
- */
- IndexFile("", n->ln_Name);
- }
- }
- ///
-
- /// UpdateMain()
- void
- UpdateMain(void)
- {
- struct FileEntry *n = SelectedMain();
-
- /* Update main windows action gadgets: no list, no action */
- TR_SetAttribute(MainPrj, MAIN_DELETE_ID, TRAT_Disabled, !n);
- TR_SetAttribute(MainPrj, MAIN_RESCAN_ID, TRAT_Disabled, !n);
- TR_SetAttribute(MainPrj, MAIN_RESCANALL_ID, TRAT_Disabled, !n);
-
- /* Update main 'references count' gadget */
- TR_SetAttribute(MainPrj, MAIN_REFERENCES_ID, TRAT_Value, n ? NumOfNodes(&n->RefsList) : 0);
-
- /* Update ref 'file' gadget */
- if (RefPrj)
- {
- TR_SetAttribute(RefPrj, REF_FILE_ID, TRAT_Text, (ULONG) (n ? (STRPTR)n->Name : (STRPTR)""));
- UpdateRef();
- }
- }
- ///
- /// UpdateRef()
- void
- UpdateRef(void)
- {
- static struct FileEntry *shown = (APTR)-1;
-
- if (RefPrj)
- {
- struct FileEntry *f = SelectedMain();
- struct RefsEntry *r = SelectedRef();
-
- /* Update ref window 'delete' gadget */
- TR_SetAttribute(RefPrj, REF_DELETE_ID, TRAT_Disabled, !r);
-
- /* Update ref window's listview if main window is changed */
- if (f != shown)
- {
- TR_SetAttribute(RefPrj, REF_LIST_ID, TRAT_Value, 0);
- TR_SetAttribute(RefPrj, REF_LIST_ID, NULL, (ULONG) (f ? &f->RefsList : &EmptyList));
- }
-
- /* Update ref windows information gadgets */
- TR_SetAttribute(RefPrj, REF_OFFSET_ID, TRAT_Value, r ? r->Offset : 0);
- TR_SetAttribute(RefPrj, REF_LENGTH_ID, TRAT_Value, r ? r->Length : 0);
- TR_SetAttribute(RefPrj, REF_GOTO_ID, TRAT_Value, r ? r->Goto : 0);
-
- shown = f;
- } else
- shown = (APTR)-1;
- }
- ///
- /// UpdateOptions()
- void
- UpdateOptions(void)
- {
- TR_SetAttribute(OptionsPrj, OPTIONS_AUTODOC_ID, TRAT_Value, Settings.AutoDocPrf.Active);
-
- TR_SetAttribute(OptionsPrj, OPTIONS_C_ID, TRAT_Value, Settings.CPrf.Active);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_DEFINE_ID, TRAT_Value, Settings.CPrf.Define);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_STRUCT_ID, TRAT_Value, Settings.CPrf.Struct);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_TYPEDEF_ID, TRAT_Value, Settings.CPrf.Typedef);
-
- TR_SetAttribute(OptionsPrj, OPTIONS_E_ID, TRAT_Value, Settings.EPrf.Active);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_CONST_ID, TRAT_Value, Settings.EPrf.Const);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_OBJECT_ID, TRAT_Value, Settings.EPrf.Object);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_PROC_ID, TRAT_Value, Settings.EPrf.Proc);
-
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_ID, TRAT_Value, Settings.AsmPrf.Active);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_EQU_ID, TRAT_Value, Settings.AsmPrf.Equ);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_STRUCTURE_ID, TRAT_Value, Settings.AsmPrf.Structure);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_MACRO_ID, TRAT_Value, Settings.AsmPrf.Macro);
-
- TR_SetAttribute(OptionsPrj, OPTIONS_RECURSIVELY_ID, TRAT_Value, Settings.Recursively);
- TR_SetAttribute(OptionsPrj, OPTIONS_KEEPEMPTY_ID, TRAT_Value, Settings.KeepEmpty);
- TR_SetAttribute(OptionsPrj, OPTIONS_UNKNOWNASAUTODOC_ID, TRAT_Value, Settings.UnknownAsAutoDoc);
-
- UpdateOptionsGhost();
- }
- ///
- /// UpdateOptionsGhost()
- void
- UpdateOptionsGhost(void)
- {
- LONG ghost;
-
- if (!OptionsPrj)
- return;
-
- ghost = !TR_GetAttribute(OptionsPrj, OPTIONS_C_ID, TRAT_Value);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_DEFINE_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_STRUCT_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_C_TYPEDEF_ID, TRAT_Disabled, ghost);
-
- ghost = !TR_GetAttribute(OptionsPrj, OPTIONS_E_ID, TRAT_Value);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_CONST_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_OBJECT_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_E_PROC_ID, TRAT_Disabled, ghost);
-
- ghost = !TR_GetAttribute(OptionsPrj, OPTIONS_ASM_ID, TRAT_Value);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_EQU_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_STRUCTURE_ID, TRAT_Disabled, ghost);
- TR_SetAttribute(OptionsPrj, OPTIONS_ASM_MACRO_ID, TRAT_Disabled, ghost);
- }
- ///
- /// UpdateSettingsStruct()
- void
- UpdateSettingsStruct(void)
- {
- Settings.AutoDocPrf.Active = TR_GetAttribute(OptionsPrj, OPTIONS_AUTODOC_ID, TRAT_Value);
-
- Settings.CPrf.Active = TR_GetAttribute(OptionsPrj, OPTIONS_C_ID, TRAT_Value);
- Settings.CPrf.Define = TR_GetAttribute(OptionsPrj, OPTIONS_C_DEFINE_ID, TRAT_Value);
- Settings.CPrf.Struct = TR_GetAttribute(OptionsPrj, OPTIONS_C_STRUCT_ID, TRAT_Value);
- Settings.CPrf.Typedef = TR_GetAttribute(OptionsPrj, OPTIONS_C_TYPEDEF_ID, TRAT_Value);
-
- Settings.EPrf.Active = TR_GetAttribute(OptionsPrj, OPTIONS_E_ID, TRAT_Value);
- Settings.EPrf.Const = TR_GetAttribute(OptionsPrj, OPTIONS_E_CONST_ID, TRAT_Value);
- Settings.EPrf.Object = TR_GetAttribute(OptionsPrj, OPTIONS_E_OBJECT_ID, TRAT_Value);
- Settings.EPrf.Proc = TR_GetAttribute(OptionsPrj, OPTIONS_E_PROC_ID, TRAT_Value);
-
- Settings.AsmPrf.Active = TR_GetAttribute(OptionsPrj, OPTIONS_ASM_ID, TRAT_Value);
- Settings.AsmPrf.Equ = TR_GetAttribute(OptionsPrj, OPTIONS_ASM_EQU_ID, TRAT_Value);
- Settings.AsmPrf.Structure = TR_GetAttribute(OptionsPrj, OPTIONS_ASM_STRUCTURE_ID, TRAT_Value);
- Settings.AsmPrf.Macro = TR_GetAttribute(OptionsPrj, OPTIONS_ASM_MACRO_ID, TRAT_Value);
-
- Settings.Recursively = TR_GetAttribute(OptionsPrj, OPTIONS_RECURSIVELY_ID, TRAT_Value);
- Settings.KeepEmpty = TR_GetAttribute(OptionsPrj, OPTIONS_KEEPEMPTY_ID, TRAT_Value);
- Settings.UnknownAsAutoDoc = TR_GetAttribute(OptionsPrj, OPTIONS_UNKNOWNASAUTODOC_ID, TRAT_Value);
- }
- ///
-
- /// HandleGUI()
- void
- HandleGUI(void)
- {
- struct TR_Message *msg;
-
- if (!TritonBase)
- return;
-
- while (msg = TR_GetMsg(Application))
- {
- if (msg->trm_Class == TRMS_HELP)
- {
- struct Window *win;
- struct Screen *scr;
-
- if (win = TR_ObtainWindow(MainPrj))
- {
- scr = win->WScreen;
- TR_ReleaseWindow(win);
- } else
- scr = NULL;
-
- GiveHelp(msg->trm_ID, scr);
- }
- else
- {
- if (msg->trm_Class == TRMS_NEWVALUE)
- HandleListViewClick(msg);
-
- if (msg->trm_Project == MainPrj)
- HandleMainIDCMP(msg);
- else if (msg->trm_Project == RefPrj)
- HandleRefIDCMP(msg);
- else if (msg->trm_Project == OptionsPrj)
- HandleOptionsIDCMP(msg);
- else if (msg->trm_Project == ScanStatPrj)
- HandleScanStatIDCMP(msg);
- }
-
- TR_ReplyMsg(msg);
- }
-
- /* Make sure that the user wants to quit */
- if ((!GoOn) && (FileChanged))
- {
- if (!rtEZRequestTags("There are changes!\nReally quit?",
- "_Okay|_Cancel",
- NULL, NULL,
-
- RT_Underscore, '_',
- TAG_END))
- GoOn = TRUE;
- }
- }
- ///
- /// HandleListViewClick()
- void
- HandleListViewClick(struct TR_Message *m)
- {
- if (m->trm_Project == MainPrj)
- {
- UpdateMain();
- if (m->trm_Qualifier & IEQUALIFIER_REPEAT)
- OpenRefWindow();
- }
- else if (m->trm_Project == RefPrj)
- UpdateRef();
- }
- ///
- /// HandleMenu()
- void
- HandleMenu(struct TR_Message *m)
- {
- switch (m->trm_ID)
- {
- case MAIN_MENU_PROJECT_CLEAR:
- LockGUI();
- if ((!FileChanged) || rtEZRequestTags("There are changes!\nReally clear the entire list?",
- "_Okay|_Cancel",
- NULL, NULL,
-
- RT_Underscore, '_',
- TAG_END))
- {
- InitializeFileList();
- UpdateMain();
-
- FileChanged = FALSE;
- }
- UnlockGUI();
- break;
-
- case MAIN_MENU_PROJECT_LOAD:
- LockGUI();
-
- if ((!FileChanged) || rtEZRequestTags("There are changes!\nReally load a new file?",
- "_Okay|_Cancel",
- NULL, NULL,
-
- RT_Underscore, '_',
- TAG_END))
- {
- if (!IsListEmpty(&FileList))
- {
- ULONG ret;
-
- ret = rtEZRequestTags( "Current list is not empty!",
- "_Replace|_Append|_Cancel",
- NULL, NULL,
-
- RT_Underscore, '_',
- TAG_END);
-
- if (ret == 0)
- {
- UnlockGUI();
- break;
- }
-
- if (ret == 1)
- {
- InitializeFileList();
- UpdateMain();
-
- FileChanged = FALSE;
- }
-
- if (ret == 2)
- FileChanged = TRUE;
- } else
- FileChanged = FALSE;
-
- LoadData(NULL);
- UpdateMain();
- }
-
- UnlockGUI();
- break;
-
- case MAIN_MENU_PROJECT_SAVE:
- LockGUI();
- SaveData(NULL);
- UnlockGUI();
- break;
-
- case MAIN_MENU_PROJECT_ABOUT:
- LockGUI();
- About();
- UnlockGUI();
- break;
-
- case MAIN_MENU_PROJECT_QUIT:
- GoOn = FALSE;
- break;
- }
- }
- ///
- /// HandleMainIDCMP()
- void
- HandleMainIDCMP(struct TR_Message *m)
- {
- if (m->trm_Class == TRMS_CLOSEWINDOW)
- {
- GoOn = FALSE;
- return;
- }
-
- HandleMenu(m);
-
- /* Check for gadgets */
- switch (m->trm_ID)
- {
- case MAIN_OPENREFWINDOW_ID:
- OpenRefWindow();
- break;
-
- case MAIN_SCAN_ID:
- struct rtFileList *selfiles;
- char tmpname[108];
-
- LockGUI();
-
- if (selfiles = rtFileRequest(AddFileReq, tmpname,
- "Select files to index...",
-
- RTFI_Flags, FREQF_MULTISELECT | FREQF_SELECTDIRS | FREQF_PATGAD,
- TAG_END))
- {
- StartScanning();
- IndexFileList(AddFileReq->Dir, selfiles);
- rtFreeFileList(selfiles);
- SortExecList(&FileList, SortCompareFunc, NULL);
- StopScanning(FALSE);
- }
-
- UnlockGUI();
- break;
-
- case MAIN_DELETE_ID:
- DeleteSelectedFile();
- break;
-
- case MAIN_OPTIONS_ID:
- if (!OptionsPrj)
- {
- TR_SetAttribute(MainPrj, MAIN_SCAN_ID, TRAT_Disabled, TRUE);
- if (OptionsPrj = TR_OpenProject(Application, OptionsOutline))
- UpdateOptions();
- else
- TR_SetAttribute(MainPrj, MAIN_SCAN_ID, TRAT_Disabled, FALSE);
- } else
- {
- struct Window *win;
-
- /* Bring the options window to the front */
- if (win = TR_ObtainWindow(OptionsPrj))
- {
- WindowToFront(win);
- ActivateWindow(win);
- TR_ReleaseWindow(win);
- }
- }
- break;
-
- case MAIN_RESCAN_ID:
- {
- struct FileEntry *f;
-
- if (f = SelectedMain())
- {
- StartScanning();
- LockGUI();
-
- /* Rescan. This will free the old references */
- IndexFile("", f->Name);
-
- UnlockGUI();
- StopScanning(FALSE);
- }
- }
- break;
-
- case MAIN_RESCANALL_ID:
- StartScanning();
- LockGUI();
-
- RescanAllFiles();
-
- UnlockGUI();
- StopScanning(FALSE);
- break;
- }
- }
- ///
- /// HandleRefIDCMP()
- void
- HandleRefIDCMP(struct TR_Message *m)
- {
- if (m->trm_Class == TRMS_CLOSEWINDOW)
- {
- TR_CloseProject(RefPrj);
- RefPrj = NULL;
- } else if (m->trm_Class == TRMS_ACTION)
- {
- if (m->trm_ID == REF_DELETE_ID)
- {
- DeleteSelectedReference();
- UpdateMain();
- }
- }
- }
- ///
- /// HandleOptionsIDCMP()
- void
- HandleOptionsIDCMP(struct TR_Message *m)
- {
- static UBYTE prefname[108];
-
- if ((m->trm_Class == TRMS_CLOSEWINDOW) || (m->trm_Class == TRMS_ACTION && m->trm_ID == OPTIONS_CANCEL_ID))
- {
- TR_CloseProject(OptionsPrj);
- OptionsPrj = NULL;
- TR_SetAttribute(MainPrj, MAIN_SCAN_ID, TRAT_Disabled, FALSE);
- }
-
- if (m->trm_Class == TRMS_ACTION)
- {
- if ((m->trm_ID == OPTIONS_USE_ID) || (m->trm_ID == OPTIONS_SAVE_ID))
- {
- UpdateSettingsStruct();
-
- if (m->trm_ID == OPTIONS_SAVE_ID)
- SaveSettings("ENVARC:FetchRefs_GI.prefs");
- SaveSettings("ENV:FetchRefs_GI.prefs");
-
- TR_CloseProject(OptionsPrj);
- OptionsPrj = NULL;
- TR_SetAttribute(MainPrj, MAIN_SCAN_ID, TRAT_Disabled, FALSE);
- }
-
- if (m->trm_ID == OPTIONS_MENU_PROJECT_OPEN_ID)
- {
- if (rtFileRequest(PrefsFileReq, prefname,
- "Load settings...",
-
- TAG_END))
- {
- BPTR newdir, olddir;
-
- if (newdir = Lock(PrefsFileReq->Dir, SHARED_LOCK))
- {
- struct Prefs tmpsettings;
-
- /* We copy to 'tmpsettings' to be able to restore the
- * original settings if Cancel is chosen. By using a
- * temporary variable only the state of the gadgets
- * is changed. The change is not permanent until Use
- * or Save is chosen.
- */
- CopyMem(&Settings, &tmpsettings, sizeof(struct Prefs));
- olddir = CurrentDir(newdir);
- LoadSettings(prefname);
- CurrentDir(olddir);
- UnLock(newdir);
- UpdateOptions();
- CopyMem(&tmpsettings, &Settings, sizeof(struct Prefs));
- }
- }
- }
-
- if (m->trm_ID == OPTIONS_MENU_PROJECT_SAVEAS_ID)
- {
- if (rtFileRequest(PrefsFileReq, prefname,
- "Save settings...",
-
- RTFI_Flags, FREQF_SAVE,
- TAG_END))
- {
- BPTR newdir, olddir;
-
- if (newdir = Lock(PrefsFileReq->Dir, SHARED_LOCK))
- {
- struct Prefs tmpsettings;
-
- /* As SaveSettings() uses the 'Settings' struct we
- * need to fill it with the current settings even
- * though they may still be Cancel'ed. Therefore we
- * copy the original back.
- */
- CopyMem(&Settings, &tmpsettings, sizeof(struct Prefs));
- UpdateSettingsStruct();
- olddir = CurrentDir(newdir);
- SaveSettings(prefname);
- CurrentDir(olddir);
- UnLock(newdir);
- CopyMem(&tmpsettings, &Settings, sizeof(struct Prefs));
- }
- }
- }
-
- if (m->trm_ID == OPTIONS_MENU_PROJECT_LASTSAVED_ID)
- {
- struct Prefs tmpsettings;
-
- /* We copy to 'tmpsettings' to be able to restore the
- * original settings if Cancel is chosen.
- */
- CopyMem(&Settings, &tmpsettings, sizeof(struct Prefs));
- LoadSettings("ENVARC:FetchRefs_GI.prefs");
- UpdateOptions();
- CopyMem(&tmpsettings, &Settings, sizeof(struct Prefs));
- }
- }
-
- if (m->trm_Class = TRMS_NEWVALUE)
- {
- if (m->trm_ID == OPTIONS_AUTODOC_ID || m->trm_ID == OPTIONS_C_ID ||
- m->trm_ID == OPTIONS_E_ID || m->trm_ID == OPTIONS_ASM_ID)
- UpdateOptionsGhost();
- }
- }
- ///
- /// HandleScanStatIDCMP()
- void
- HandleScanStatIDCMP(struct TR_Message *m)
- {
- if ((m->trm_Class == TRMS_CLOSEWINDOW) || (m->trm_Class == TRMS_ACTION && m->trm_ID == SCANSTAT_STOP_ID))
- StopScanning(TRUE);
- }
- ///
-
- /// NumOfNodes()
- ULONG
- NumOfNodes(struct List *l)
- {
- struct Node *n = GetHead(l);
- ULONG cnt = 0;
-
- while (n->ln_Succ)
- {
- cnt++;
- n = n->ln_Succ;
- }
-
- return(cnt);
- }
- ///
- /// SelectedMain()
- struct FileEntry *
- SelectedMain(void)
- {
- struct FileEntry *f;
-
- /* Find pointer to selected node in main listview */
- if (IsListEmpty(&FileList))
- f = NULL;
- else
- {
- ULONG cnt;
-
- f = (struct FileEntry *)GetHead(&FileList);
- cnt = TR_GetAttribute(MainPrj, MAIN_LIST_ID, TRAT_Value);
- while (cnt--)
- f = f->node.ln_Succ;
- }
- return(f);
- }
- ///
- /// SelectedRef()
- struct RefsEntry *
- SelectedRef(void)
- {
- struct FileEntry *f = SelectedMain();
- struct RefsEntry *r;
-
- /* Find pointer to selected node in main listview */
- if ((f == NULL) || (IsListEmpty(&f->RefsList)))
- r = NULL;
- else
- {
- ULONG cnt;
-
- r = (struct RefsEntry *)GetHead(&f->RefsList);
- cnt = TR_GetAttribute(RefPrj, REF_LIST_ID, TRAT_Value);
- while (cnt--)
- r = r->node.ln_Succ;
- }
- return(r);
- }
- ///
-
- /// GoGUI()
- void
- GoGUI(void)
- {
- if (!ReqToolsBase)
- CloseGUI();
-
- if (!TR_OpenTriton(TRITON14VERSION,
- TRCA_Name, "GenerateIndex",
- TRCA_LongName, "FetchRefs' GenerateIndex",
- TRCA_Info, "Index file generator for FetchRefs",
- TRCA_Version, VERSION,
- TRCA_Release, RELEASE,
- TRCA_Date, DATE,
- TAG_END))
- CloseGUI();
-
- if (!(DataFileReq = rtAllocRequestA(RT_FILEREQ, NULL)))
- CloseGUI();
-
- if (!(AddFileReq = rtAllocRequestA(RT_FILEREQ, NULL)))
- CloseGUI();
- rtChangeReqAttr(AddFileReq, RTFI_MatchPat, "~(#?.(guide|a|c|e|o))", TAG_END);
-
- if (!(PrefsFileReq = rtAllocRequestA(RT_FILEREQ, NULL)))
- CloseGUI();
-
- /* Load a data file if any is specified by tool types/Shell arguments */
- if (DataName[0])
- {
- STRPTR p;
-
- LoadData(DataName);
- p = PathPart(DataName);
-
- /* If a path is specified we split up in path and file name */
- if (p != DataName)
- {
- UBYTE c;
-
- c = *p;
- *p = 0;
- rtChangeReqAttr(DataFileReq, RTFI_Dir, DataName, TAG_END);
- *p = c;
- strcpy(DataName, FilePart(DataName));
- }
- }
-
- if (!(MainPrj = TR_OpenProject(Application, MainOutline)))
- CloseGUI();
-
- UpdateMain();
-
- while (GoOn)
- {
- TR_Wait(Application, NULL);
- HandleGUI();
- }
-
- CloseGUI();
- }
- ///
- /// CloseGUI()
- void
- CloseGUI(void)
- {
- if (ReqToolsBase)
- {
- rtFreeRequest(DataFileReq);
- rtFreeRequest(AddFileReq);
- rtFreeRequest(PrefsFileReq);
- } else
- CloseAll(ERROR_CUSTOM, "You need ReqTools version 38+ for the GUI!");
-
- if (TritonBase)
- {
- if (MainPrj)
- TR_CloseProject(MainPrj);
- if (RefPrj)
- TR_CloseProject(RefPrj);
- if (OptionsPrj)
- TR_CloseProject(OptionsPrj);
- TR_CloseTriton();
- } else
- CloseAll(ERROR_CUSTOM, "You need Triton version 5+!");
- }
- ///
-